package sf.database.dao;

/**
 * sql执行上下文
 */
public class DBContext {
    /**
     * 数据源名称
     */
    private String dataSource;

    /**
     * 是否无事务,对jta事务无效
     */
    private boolean noTransaction;

    /**
     * 查询超时设置(s)
     */
    private int queryTimeout;

    /**
     * 是否使用tail
     */
    private boolean useTail;
    /**
     * 是否保留DBObject中的updateMap
     */
    private boolean keepUpdate;

    /**
     * 动态表名(只针对对象操作生效)
     */
    private String dynamicTableName;

    /**
     * sql模板id是否使用方言,主要控制sqlId前面是否添加数据库名称(selectUser变为mysql.selectUser)
     * 优先级比@SqlResource高
     */
    private boolean sqlTemplateIdUseDialect;

    public DBContext() {

    }

    /**
     * @param dataSource 数据源名称
     */
    public DBContext(String dataSource) {
        this.dataSource = dataSource;
    }

    /**
     * @param noTransaction 使用原始连接
     */
    public DBContext(boolean noTransaction) {
        this.noTransaction = noTransaction;
    }

    /**
     * @param dataSource    数据源名称
     * @param noTransaction 使用原始连接
     */
    public DBContext(String dataSource, boolean noTransaction) {
        this.dataSource = dataSource;
        this.noTransaction = noTransaction;
    }

    public String getDataSource() {
        return dataSource;
    }

    public void setDataSource(String dataSource) {
        this.dataSource = dataSource;
    }

    public boolean isNoTransaction() {
        return noTransaction;
    }

    public void setNoTransaction(boolean noTransaction) {
        this.noTransaction = noTransaction;
    }

    public int getQueryTimeout() {
        return queryTimeout;
    }

    public void setQueryTimeout(int queryTimeout) {
        this.queryTimeout = queryTimeout;
    }

    public boolean isUseTail() {
        return useTail;
    }

    public void setUseTail(boolean useTail) {
        this.useTail = useTail;
    }

    public boolean isKeepUpdate() {
        return keepUpdate;
    }

    public void setKeepUpdate(boolean keepUpdate) {
        this.keepUpdate = keepUpdate;
    }

    public String getDynamicTableName() {
        return dynamicTableName;
    }

    public void setDynamicTableName(String dynamicTableName) {
        this.dynamicTableName = dynamicTableName;
    }

    public boolean isSqlTemplateIdUseDialect() {
        return sqlTemplateIdUseDialect;
    }

    public void setSqlTemplateIdUseDialect(boolean sqlTemplateIdUseDialect) {
        this.sqlTemplateIdUseDialect = sqlTemplateIdUseDialect;
    }
}
